<script setup>
import {ref} from "vue";
import request  from '@/api/request'

let emits=defineEmits(["ref-table1"])


let page=ref({
    current:1,
    size:5,
    total:0,
    records:[]
})


let onSubmit=()=>{
    emits("ref-table1", Material)
}
let Material=ref([])
//选择框事件
let fuxuankuang=(a)=>{
    Material.value=a;
}
//查询产品信息
let location=()=>{
    request({
        //查询客户
        url:"/material/index",
        method:"get",
        params:{
            current:page.value.current,
            size:page.value.size,
            materialOrProduct:"产品",
            isEnabled:0
        }
    }).then(res=>{
        page.value=res.data
    })
}

location();

</script>
<template>
    <div>
        <el-card>
            <template #header>
                <el-table :data="page.records" border stripe @selection-change="fuxuankuang">
                    <el-table-column type="selection" width="55"/>
                    <el-table-column prop="materialId" label="物料编码"/>
                    <el-table-column prop="materialName" label="物料名称"/>
                    <el-table-column prop="specificationsAndModels" label="规格型号"/>
                    <el-table-column prop="unit" label="单位"/>
                    <el-table-column prop="category" label="所属分类名称"/>
                </el-table>

                <el-pagination @current-change="location" v-model:currentPage="page.current"
                    :page-sizes="[2, 4, 6, 8, 10]" :page-size="page.size" :total="page.total" background style="margin: 10px 0px;">
                </el-pagination>
                
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">立即添加</el-button>
                </el-form-item>
            </template>
        </el-card>
    </div>
</template>
<style scoped>

</style>